package com.ym.b2b.commons.controller;

import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zc.commons.base.Result;
import com.zc.commons.spring.SpringContextHolder;

/**
 * cache 管理
 * 
 * @ClassName: CacheManagerController
 * @Description: TODO
 * @Author 竺夏军
 * @Date 2015年5月7日 下午8:13:15
 * @Modify
 * @CopyRight 信息化团队
 */
@Controller
@RequestMapping("/cache")
public class CacheManagerController {

    @RequestMapping(value = "refreshCacheAll.s")
    @ResponseBody
    public Result refreshCacheAll(String cacheName) {

        Result ret = new Result();

        try {
            EhCacheCacheManager cacheManager = SpringContextHolder.getBean("cacheManager");

            cacheManager.getCacheManager().clearAll();

            ret.setResult("刷新缓存成功..");
        } catch (Exception e) {
            e.printStackTrace();
            ret.setCodeResult(Result.CODE_100, "清除失败:" + e.getMessage());
        }

        return ret;
    }
}
